<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/commons/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  	<title>分配权限</title>
  </head>
  <body class="container">
	<ul id="permisstionTree" class="ztree" style="margin: 10% 0 0 20%;max-height: 60%"></ul>
	<div class="row">
		<button class="btn btn-primary center-block" onclick="setPermi()">设置</button>
	</div>
  <link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
  <script type="text/javascript" src="${ctx}/static/js/zTree_v3/js/jquery.ztree.all-3.5.min.js"></script>
   	<script type="text/javascript">
   	var permTree,setting = {
   		view:{selectedMulti:false},
   		check:{enable:true},
   		callback:{
   		   	onClick:function(event,treeId,treeNode){
   		   	}
   		},
		data: {
			simpleData: {
  					pIdKey:"pid",
				enable: true
			}
		}
		};
	function setPermi(){
		var layerLoadIndex= layer.load(2);
		var permis=[],slctNodes = permTree.getCheckedNodes(true);
		for(var nId in slctNodes){
			permis.push(slctNodes[nId].id);
			}
		$.post("${ctx}/admin/role/setPermi",{roleId:'${roleId}',permis:permis},function(d){
			layer.alert(d.msg);
			layer.close(layerLoadIndex);
			if(d.success){
				
				}
			},"json");
		}
 	$(function(){
 	 permTree=$.fn.zTree.init($("#permisstionTree"),setting,eval('${permissionTree}'));
 	 permTree.expandAll(true);
		$("#form").Validform({
			tiptype:4
			})
		});
	</script>
  </body>
</html>
